package com;

import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YJ
 * Date: 2024-6-23
 * Time: 20:22
 */
public class ToUpperCase1 {
    public static void main(String[] args) {
        //创建文件字符输入/输出流
        String inputFile = "D:\\storage\\homework\\exercise-6-23\\src\\com\\input.txt";
        String outputFile = "D:\\storage\\homework\\exercise-6-23\\src\\com\\output.txt";

        try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));
             BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
            //定义变量读取一行字符数据
            String line;
            while ((line = reader.readLine()) != null) {
                //调用函数:
                // (toUpperCase()小写-->大写)
                // (toLowerCase():大写-->小写)
                String upperCaseLine = line.toUpperCase();
                //把转换后的字符写入新文件中
                writer.write(upperCaseLine);
                writer.newLine();
            }
            System.out.println("successfully.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
